import 'package:flutter/material.dart';
import 'package:wechat_app/widgets/dialog/more_dialog.dart';

class Wechat extends StatefulWidget {
  const Wechat({super.key});

  @override
  State<Wechat> createState() => _WechatState();
}

class _WechatState extends State<Wechat> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        centerTitle: true,
        elevation: 0,
        backgroundColor: const Color(0xffEDEDED),
        actions: [
          // 使用Builder获取当前实例的context
          Builder(builder: (context) {
            return InkWell(
                onTap: () {
                  moreDialog(context);
                },
                child: const Padding(
                  padding: EdgeInsets.all(10),
                  child: Icon(
                    Icons.add_circle_outline,
                    color: Color(0xff1C1C1C),
                  ),
                ));
          })
        ],
        title: const Text(
          "微信",
          style: TextStyle(color: Color(0xff181818), fontSize: 16),
        ),
      ),
      body: Column(children: [
        // double.infinity:100%
        Container(
          color: const Color(0xffEDEDED),
          width: double.infinity,
          padding: const EdgeInsets.only(left: 8, right: 8, bottom: 10),
          child: InkWell(
            onTap: () {
              print("跳转搜索页");
            },
            child: Container(
                padding: const EdgeInsets.symmetric(vertical: 6),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(4)),
                child:
                    Row(mainAxisAlignment: MainAxisAlignment.center, children: [
                  Image.asset("assets/images/search.png",
                      width: 17, height: 17),
                  const SizedBox(width: 7),
                  const Text("搜索",
                      style: TextStyle(color: Color(0xffB3B3B3), fontSize: 16))
                ])),
          ),
        ),
        Expanded(child: ListView.builder(itemBuilder: (context, index) {
          return Padding(
              padding: const EdgeInsets.all(13),
              child: Row(
                children: [
                  Stack(
                    children: [
                      Container(
                        margin: const EdgeInsets.only(top: 10, right: 17),
                        child: ClipRRect(
                            borderRadius: BorderRadius.circular(8),
                            child: Image.network(
                              "https://img2.baidu.com/it/u=175449109,3788073609&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1681578000&t=530a0603d724ea6ba516038f2a7a8194",
                              width: 48,
                              height: 48,
                              fit: BoxFit.cover,
                            )),
                      ),
                      Positioned(
                          top: 0,
                          left: 38,
                          child: Container(
                            decoration: BoxDecoration(
                                color: const Color(0xffFA5151),
                                borderRadius: BorderRadius.circular(18)),
                            padding: const EdgeInsets.symmetric(
                                horizontal: 5, vertical: 2),
                            child: const Text(
                              "1",
                              style:
                                  TextStyle(color: Colors.white, fontSize: 12),
                            ),
                          ))
                    ],
                  ),
                  Expanded(
                      child: Container(
                    height: 72,
                    decoration: const BoxDecoration(
                        border: Border(
                            bottom: BorderSide(color: Color(0xffE5E5E5)))),
                    child: const Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: [
                        Row(
                          children: [
                            Expanded(
                                child: Text(
                              "玖溺堔嗨つ",
                              style: TextStyle(
                                  color: Color(0xff1A1A1A), fontSize: 16),
                            )),
                            Text(
                              "昨天 15:31",
                              style: TextStyle(
                                  color: Color(0xffCDCDCD), fontSize: 12),
                            )
                          ],
                        ),
                        // SizedBox(
                        //   height: 6,
                        // ),
                        Text(
                          "听说你很牛",
                          textAlign: TextAlign.left,
                          style:
                              TextStyle(color: Color(0xffB3B3B3), fontSize: 13),
                        )
                      ],
                    ),
                  ))
                ],
              ));
        }))
      ]),
    );
  }
}
